package Stages

import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.TextureRegion
import com.badlogic.gdx.scenes.scene2d.Stage
import com.badlogic.gdx.scenes.scene2d.ui.Image
import floatHeight
import floatWidth
import setOnTouchListener
import stageFlag

/**
 * 开始舞台
 */
class StartStage : Stage()
{
    private val texture by lazy { Texture(Gdx.files.internal("open.png")) }
    private val startRegion by lazy { TextureRegion(texture, 0, 0, 800, 480) }
    private val btnRegion by lazy { TextureRegion(texture, 918, 0, 105, 39) }
    private val startImage by lazy { Image(startRegion) }
    private val startBtnImage by lazy { Image(btnRegion) }

    init
    {
        startImage.setSize(Gdx.graphics.floatWidth, Gdx.graphics.floatHeight)
        startBtnImage.setSize(80f, 30f)
        startBtnImage.translate(48f, Gdx.graphics.floatHeight - 75)

        addActor(startImage)
        addActor(startBtnImage)

        startBtnImage.setOnTouchListener { image, touchState ->
            if (touchState == TouchState.touchUp)
            {
                stageFlag = MainPage.STAGE_FLAG.GAME
            }
        }
    }
}